package com.example.demo.config;


public enum RetEnum {


    /**
     * 成功返回码
     */
    Succeeded(0, "成功"),
    /**
     * 失败返回码
     */
    Failed(1, "失败"),

    Not_Exit_User(3000, "不存在该用户"),
    User_Password_Error(3001, "输入的密码错误"),
    Token_Expire(3002,"token过期或者无效"),


    Not_Exit_Teacher(300,"该用户不存在"),
    Teacher_Password_Error(301,"密码错误");

    private int code;
    private String message;

    RetEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int asCode() {
        return code;
    }

    public String asMessage() {
        return message;
    }


    public static RetEnum get(int code) {
        for (RetEnum a : RetEnum.values()) {
            if (a.code == code) {
                return a;
            }
        }
        return RetEnum.Failed;
    }

    public static RetEnum getEnum(int code) {
        for (RetEnum a : RetEnum.values()) {
            if (a.code == code) {
                return a;
            }
        }
        return null;
    }
}
